package model;

import java.awt.Graphics;
import java.util.List;

/**
 *
 * <p>
 * Title: DrawableRoute</p>
 * <p>
 * Description: CS 343 Project. Allows routes to be drawn on map.</p>
 *
 * @date 11/18/2013
 *
 * @author Dylan Ahmann - Class programming
 * @author Gregg Roemhildt - paint method and Javadocs
 * @author Sam Brockmann - Javadocs
 * @author Emily Hancock - Javadocs
 * @author Shirin Asadi
 *
 */
public class DrawableRoute extends Route<double[]> implements Drawable {

    /**
     * default constructor
     *
     * Initializes route.
     */
    public DrawableRoute() {
        super();
    }

    /**
     * alternate constructor
     *
     * @param v list of vertices
     */
    public DrawableRoute(List<Vertex> v) {
        super(v);
    }

    /**
     * paint Paints a route on the map.
     *
     * @param g defines color pattern
     *
     */
    @Override
    public void paint(Graphics g) {
        Vertex<double[]> prev = null;
        for (Vertex v : path) {
            DrawableVertex d = new DrawableVertex(v);
            d.paint(g);
            if (prev != null) {
                DrawableEdge e = new DrawableEdge(v, prev);
                e.paint(g);
            }
            prev = v;
        }
    }

    /**
     * paint (overloaded) Paints a route on the map.
     *
     * @param g defines color pattern
     * @param x x-offset
     * @param y y-offset
     * @param z zoom level
     */
    public void paint(Graphics g, double x, double y, double z) {
        Vertex<double[]> prev = null;
        for (Vertex v : path) {
            DrawableVertex d = new DrawableVertex(v);
            d.paint(g, x, y, z);
            if (prev != null) {
                DrawableEdge e = new DrawableEdge(v, prev);
                e.paint(g, x, y, z);
            }
            prev = v;
        }
    }
}
